/*
	NGUOI TAO LOCLV
	NGAY TAO  13/4/2011
TRUYEN VAO 2 THAM SO
	1 TENDN
	2 MATKHAU
	OUTPUT:1 BIEN (RESULT) DE BIET CO DANG NHAP THANH CONG HAY KHONG
	RESULT = 1 DANG NHAP THANH CONG
	RESULT = 0 DANG NHAP THAT BAI
*/

IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME='SP_KIEMTRATENDANGNHAP')
BEGIN
	DROP PROC  SP_KIEMTRATENDANGNHAP
END
GO
CREATE PROC  SP_KIEMTRATENDANGNHAP
	-- TAT CA THAM SO IN+OUT 
	@TENDN		NVARCHAR(30),
	@MATKHAU	NVARCHAR(30),
	@RESULT		INT OUTPUT
AS
BEGIN
	-- CHUA DOAN LENH XU LY
	IF EXISTS (SELECT * FROM THANHVIEN WHERE TENDN=@TENDN AND MATKHAU=@MATKHAU)
	BEGIN
		SET @RESULT=1
		PRINT 'DANG NHAP THANH CONG'
	END
	ELSE
	BEGIN
		SET @RESULT=0
		PRINT 'DANG NHAP THAT BAI'
	END 
END

-- THUC THI
-- DECLARE DINH NGHIA
DECLARE @RESULT INT
EXEC SP_KIEMTRATENDANGNHAP 'ABC','ABC',@RESULT OUTPUT
SELECT @RESULT AS 'RESULT'